package com.dingwei.superiordiary.ui.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.dingwei.superiordiary.R;
import com.dingwei.superiordiary.bean.SetStateBean;
import com.dingwei.superiordiary.mvp.presenter.ReviewPermissionsSetPresenter;
import com.dingwei.superiordiary.mvp.view.Contract;
import com.lihao.baselibrary.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author 南柯一梦丶
 * Created time 2018/10/25.
 * Personal signature 余生还长 何必慌张
 * Page description :
 * .::::.
 * .::::::::.
 * :::::::::::
 * ..:::::::::::'
 * '::::::::::::'
 * .::::::::::
 * '::::::::::::::..
 * ..::::::::::::.
 * ``::::::::::::::::
 * ::::``:::::::::'        .:::.
 * ::::'   ':::::'       .::::::::.
 * .::::'      ::::     .:::::::'::::.
 * .:::'       :::::  .:::::::::' ':::::.
 * .::'        :::::.:::::::::'      ':::::.
 * .::'         ::::::::::::::'         ``::::.
 * ...:::           ::::::::::::'              ``::.
 * ```` ':.          ':::::::::'                  ::::..
 * '.:::::'                    ':'````..
 */
public class ReviewPermissionsActivity extends BaseActivity implements Contract.ReviewPermissionsView {

    ReviewPermissionsSetPresenter reviewPermissionsSetPresenter = new ReviewPermissionsSetPresenter(this);
    @Bind(R.id.img_back)
    ImageView imgBack;
    @Bind(R.id.tv_title)
    TextView tvTitle;
    @Bind(R.id.tv_right)
    TextView tvRight;
    @Bind(R.id.img_all)
    ImageView imgAll;
    @Bind(R.id.img_not_attention)
    ImageView imgNotAttention;
    @Bind(R.id.img_img_not_attention_me)
    ImageView imgImgNotAttentionMe;

    @Override
    public void setData(SetStateBean bean) {

        switch (bean.data.comment_auth) {
            case "1":
                imgAll.setImageResource(R.mipmap.ic_set_open);
                imgNotAttention.setImageResource(R.mipmap.ic_set_close);
                imgImgNotAttentionMe.setImageResource(R.mipmap.ic_set_close);
                break;
            case "2":
                imgAll.setImageResource(R.mipmap.ic_set_close);
                imgNotAttention.setImageResource(R.mipmap.ic_set_open);
                imgImgNotAttentionMe.setImageResource(R.mipmap.ic_set_close);
                break;
            case "3":
                imgAll.setImageResource(R.mipmap.ic_set_close);
                imgNotAttention.setImageResource(R.mipmap.ic_set_close);
                imgImgNotAttentionMe.setImageResource(R.mipmap.ic_set_open);
                break;
        }
    }

    @Override
    public void commentAuthStateSuccess() {
        reviewPermissionsSetPresenter.initData();
    }


    @Override
    protected int getContentViewId() {
        return R.layout.activity_review_permissions;
    }

    @Override
    protected void initData() {
        reviewPermissionsSetPresenter.initData();
    }

    @Override
    protected void initView() {
        tvTitle.setText("个人说评论权限");
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.img_back, R.id.img_all, R.id.img_not_attention, R.id.img_img_not_attention_me})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_back:
                finish();
                break;
            case R.id.img_all:
                reviewPermissionsSetPresenter.commentAuthState("1");
                break;
            case R.id.img_not_attention:
                reviewPermissionsSetPresenter.commentAuthState("2");
                break;
            case R.id.img_img_not_attention_me:
                reviewPermissionsSetPresenter.commentAuthState("3");
                break;
        }
    }
}
